package cn.market.service.privilege.impl;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Service;

import cn.market.bean.privilege.SystemPrivilege;
import cn.market.service.base.DaoSupport;
import cn.market.service.privilege.SystemPrivilegeService;

@Service
public class SystemPrivilegeServiceBean extends DaoSupport<SystemPrivilege> implements SystemPrivilegeService {
	
	public void batchSave(List<SystemPrivilege> privileges){
		for(SystemPrivilege p : privileges){
			save(p);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<SystemPrivilege> getAllMarketSystemPrivilege() {
		String hql = "from SystemPrivilege s where s.type=?1";
		Query query = super.em.createQuery(hql);
		query.setParameter(1, 0);
		return (List<SystemPrivilege>)query.getResultList();
	}
	
	
}
